<template>
    <view class="scan_sure_container">
        <view class="scan_sure_mendian_block">
            <view class="scan_sure_mendian_info">
                <view class="scan_sure_mendian_info_item">
                    <image src="../../static/mendian.png" class="scan_sure_mendian_icon"></image>
                    <text class="scan_sure_mendian_name">：省老干局古田大院</text>
                </view>
                <view class="scan_sure_mendian_info_item">
                    <image src="../../static/jizi.png" class="scan_sure_mendian_icon"></image>
                    <text class="scan_sure_mendian_name">：KKSD6K20092100190</text>
                </view>
            </view>
            <view class="scan_sure_mendian_banner">
                <swiper class="SwiperIndex" autoplay="true" :indicator-dots="true" interval="5000" duration="500" @change="swiperChange">
                    <swiper-item style="border-radius: 20rpx" v-for="(item, swiper) in bannerList" :key="swiper">
                      <image mode="aspectFill" :src="item + '?x-oss-process=style/normal'" style="border-radius: 20rpx"></image>
                    </swiper-item>
                </swiper>
            </view>
        </view>
        <view class="scan_sure_other_banner">
            <swiper style="height: 200rpx;" class="SwiperIndex" autoplay="true" :indicator-dots="true" interval="5000" duration="500" @change="swiperChange">
                <swiper-item style="border-radius: 20rpx" v-for="(item, swiper) in bannerOtherList" :key="swiper">
                  <image mode="aspectFill" :src="item + '?x-oss-process=style/normal'" style="border-radius: 20rpx"></image>
                </swiper-item>
            </swiper>
        </view>
        <view class="scan_sure_content">
            <view class="scan_sure_content_top">
                <view class="scan_sure_money_info">
                    <view class="scan_sure_money_info_title_block">
                        <image src="../../static/jifei.png" class="scan_sure_money_info_title_icon"></image>
                        <text class="scan_sure_money_info_title_text">计费标准:</text>
                    </view>
                    <view class="scan_sure_money_info_value">1元/半小时</view>
                </view>
                <view class="scan_sure_equipment_list_blcok">
                    <view class="scan_sure_equipment_list">
                        <image src="../../static/tc.png" class="scan_sure_equipment_item_icon"></image>
                        <image src="../../static/anzhuo.png" class="scan_sure_equipment_item_icon"></image>
                        <image src="../../static/apple.png" class="scan_sure_equipment_item_icon"></image>
                    </view>
                    <text class="scan_sure_equipment_text">支持常见设备租赁</text>
                </view>
            </view>
            <view class="scan_sure_content_tip">
                <text class="scan_sure_content_tip_text">
                    租借前5分钟免费，日封顶35元，总封顶99元，支持免押服务。
                </text>
            </view>
        </view>
        <view class="bottom_btn_block">
            <view class="bottom_btn" @tap="payFun()">
                <text class="">免押金租借</text>
                <text class="">(支付分550以上有机会)</text>
            </view>
            <view class="agreement">
              <icon v-if="!agreementState" @tap="changeAgreement" data-type="1" type="circle" size="40rpx"></icon> 
              <icon v-else @tap="changeAgreement" data-type="0" type="success" size="40rpx"></icon>
              <text class="agreementTip">勾选同意</text>
              <text class="agreementName" @click.stop="tolinkUrl" data-link="custom_page_order_agreement.html">《委托扣款授权书》</text>
            </view>
        </view>
    </view>
</template>

<script>

export default {
  data() {
    return {
      setting: null,
      agreementState:true,
      bannerList:[
          'http://image1.sansancloud.com/qijiang/2021_1/25/15/3/22_179.jpg',
          'http://image1.sansancloud.com/qijiang/2021_1/25/14/24/39_356.jpg',
          'http://image1.sansancloud.com/xiaogu/2021_1/25/16/22/53_22.jpg'
      ],
      bannerOtherList:[
          'http://image1.sansancloud.com/xiaogu/2020_12/15/15/2/45_91.jpg',
          'http://image1.sansancloud.com/xiaogu/2021_1/25/16/22/53_426.jpg',
      ],
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this;
    // uni.setNavigationBarColor({
    //   frontColor: '#ffffff',
    //   backgroundColor: '#59bfba'
    // });
    // that.getData(that.params);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    // this.getData(this.params);
    uni.showNavigationBarLoading();
    uni.hideNavigationBarLoading(); //完成停止加载

    uni.stopPullDownRefresh(); //停止下拉刷新
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  },
  methods: {
    ad:function(){
        console.log("===uni.openBusinessView===")
        if (uni.openBusinessView) {
          uni.openBusinessView({
            businessType: 'wxpayScoreEnable',
            extraData: {
              
            },
            success() {
              //dosomething
            },
            fail() {
              //dosomething
            },
            complete() {
              //dosomething
            }
          });
        } else {
          //引导用户升级微信版本
        }
    },
    changeAgreement(e) {
      let that = this;
      console.log('checkbox发生change事件，携带value值为：', e);
      let type = e.target.dataset.type;
    
      if (type == 1) {
        that.setData({
          agreementState: true
        });
      } else {
        that.setData({
          agreementState: false
        });
      }
    },
    swiperChange:function(){
        
    },
    tolinkUrlFun:function(url){
        if(url){
            uni.navigateTo({
              url: '/pages/'+url+'/index'
            });
        }
    },
    /* 获取数据 */
    payFun: function () {
      var that = this;
      if(!that.agreementState){
          uni.showToast({
            title: "请先勾选同意以下协议",
            icon:"none",
            // image: '/static/tip.png',
            duration: 2000
          });
          return
      }
      console.log("===openid==",getApp().globalData.openid)
      let param={
          shop_id:36,
          user_id:'2563',
          order_number:getApp().globalData.openid,
          shop_name:"测试店铺"
      }
      var customIndex = getApp().globalData.AddClientUrl("/order/in_wx_order", param);
      getApp().globalData.showToastLoading('loading', true);
      uni.request({
          url: customIndex.url,
          data: customIndex.params,
          header: getApp().globalData.header,
          method: 'GET',
        success: function (res) {
          uni.hideLoading();
          console.log(res.data);
          uni.hideLoading();
        },
        fail: function (res) {
          console.log("fail");
          uni.hideLoading();
          getApp().globalData.loadFail();
        }
      });
    },
    setData: function (obj) {
      let that = this;
      let keys = [];
      let val, data;
      Object.keys(obj).forEach(function (key) {
        keys = key.split('.');
        val = obj[key];
        data = that.$data;
        keys.forEach(function (key2, index) {
          if (index + 1 == keys.length) {
            that.$set(data, key2, val);
          } else {
            if (!data[key2]) {
              that.$set(data, key2, {});
            }
          }

          data = data[key2];
        });
      });
    }
  }
};
</script>
<style>
@import "./lease.css";
</style>